package com.hedy.order.service.impl;

import com.hedy.order.feign.UserFeignClient;
import com.hedy.order.service.OrderService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import dto.OrderDTO;
import dto.UserDTO;
import response.OrderResponse;

@Service
public class OrderServiceImpl implements OrderService {

    @Qualifier("com.hedy.order.feign.UserFeignClient")
    @Autowired
    UserFeignClient userFeignClient;
    @Override
    public OrderResponse getOrders(Integer uid) {
        List<OrderDTO> orders = new ArrayList<>();
        for (int i = 1; i < 5; i++) {
            orders.add(new OrderDTO(1001, 1850.00F + i, new Date()));
        }
        UserDTO user = userFeignClient.getUserInfo(uid);
        return new OrderResponse(uid,user.getUsername(),orders);
    }
}
